a = input()
mx = 0
for i in range(len(a)):
    for r in range(i,len(a)):
        b = int(a[i:r+1]) 
        k = 0
        for c in range(1, b+1):
            if b%c == 0:
                k += 1
        if k == 2:
            mx = max(mx,b)
print(mx)
